package cn.xxstudy.blog.config

import org.springframework.web.servlet.HandlerInterceptor
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

/**
 * 作者：wuxinxi on 2020/11/26
 * 包名：cn.xxstudy.blog.config
 * TODO:检查登录拦截器
 */
class LoginInterceptor : HandlerInterceptor {
    override fun preHandle(request: HttpServletRequest, response: HttpServletResponse, handler: Any): Boolean {
        if (request.session.getAttribute("user") == null) {
            response.sendRedirect("/admin")
            return false
        }
        return true
    }
}